/**
 * 详情对话框
 */
var SysProtocolInfoDlg = {
    data: {
        protocol: "",
        title:"",
        type:""
    }
};

layui.use(['form', 'admin', 'ax' , 'layedit'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layedit = layui.layedit;


    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/sysProtocol/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('sysProtocolForm', result.data);
    $("#container").val(result.data.protocol) ;
    var index = layedit.build('container', {
        height: 180, //设置编辑器高度
        tool: ['left' //左对齐
            ,'center' //居中对齐
            ,'right']
    });

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        layedit.sync(index);
        var protocol = layedit.getContent(index);
        data.field.protocol=protocol;
        var ajax = new $ax(Feng.ctxPath + "/sysProtocol/editItem", function (data) {
            Feng.success("更新成功！");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();

        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

});